package com.wdxy.annotation;

import java.lang.reflect.Method;

import javax.print.attribute.standard.Destination;

import com.sun.swing.internal.plaf.metal.resources.metal;

public class TestAnn {

	public static void main(String[] args) {
		//1.使用类加载器加载类
		try {
			Class c = Class.forName("com.wdxy.annotation.AnnChild");
			//2.找到类上面的注解
			boolean isExist = c.isAnnotationPresent(Desc.class);
			if (isExist) {
				//3.拿到注解实例
				Desc d = (Desc) c.getAnnotation(Desc.class);
				System.out.println(d.value());
			}
			//4.找到方法上的注解
			Method[] ms = c.getMethods();
			for(Method m : ms){
				boolean isMExist = m.isAnnotationPresent(Desc.class);
				if(isMExist){
					Desc d = m.getAnnotation(Desc.class);
					System.out.println(d.value());
				}
			}
				
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
